<template>
  <!-- 快捷键功能实现类 -->
  <div></div>
</template>

<script>
import hotkeys from 'hotkeys-js'
export default {
  name: 'Hotkeys',
  components: {},
  computed: {},

  data() {
    return {
      form: {
        call: '*',
        transfer: '-',
        consult: 'Control+3',
        turnOff: 'Control+4',
        answer: 'Space',
        hold: 'Page Up',
        unHold: 'Page Down',
        monitor: 'Control+5',
        forceInsert: 'Insert',
        forceRelease: 'Delect',
        dial: 'Enter',
        reCall: 'Home',
      },
    }
  },
  methods: {
    //初始化快捷键
    init() {
      let _this = this
      //拨号
      hotkeys(_this.form.dial, function (event, handler) {
        _this.$emit('handleDialog')
      })
      //呼叫
      hotkeys(_this.form.call, function (event, handler) {
        _this.$emit('handleDoCall', 'audio')
      })
      //转接
      hotkeys(_this.form.transfer, function (event, handler) {
        _this.$emit('handleDoCall', 'trans')
      })
      //咨询呼叫
      hotkeys(_this.form.consult, function (event, handler) {
        _this.$emit('handleDoCall', 'consult')
      })
      //挂机
      hotkeys(_this.form.turnOff, function (event, handler) {
        _this.$emit('handleTurnOff')
      })
      //应答
      hotkeys(_this.form.answer, function (event, handler) {
        _this.$emit('handleAnswer')
      })
      //保持
      hotkeys(_this.form.hold, function (event, handler) {
        _this.$emit('handleHoldAndUn')
      })
      //解除保持
      hotkeys(_this.form.unHold, function (event, handler) {
        _this.$emit('handleHoldAndUn')
      })
      //监听
      hotkeys(_this.form.monitor, function (event, handler) {
        _this.$emit('handleForce', 'MonitorCall')
      })
      //强插
      hotkeys(_this.form.forceInsert, function (event, handler) {
        _this.$emit('handleForce', 'ForceInsertCall')
      })
      //强拆
      hotkeys(_this.form.forceRelease, function (event, handler) {
        _this.$emit('handleForce', 'ForceReleaseCall')
      })
      //重拨
      hotkeys(_this.form.reCall, function (event, handler) {})
    },
  },
  mounted() {
    this.init()
  },
}
</script>

<style  lang="scss" scoped>
</style>
